home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Development Tools & Languages / Dylan Related / Mindy / Mindy 1.2 - portable sources / libraries / dylan / exit.dylan < prev    next >
Encoding:
Text File  |  1995-03-15  |  1.5 KB  |  44 lines  |  [TEXT/ttxt]

  1. module: dylan
  2. rcs-header: $Header: exit.dylan,v 1.4 94/11/03 23:50:59 wlott Exp $
  3.  
  4. //======================================================================
  5. //
  6. // Copyright (c) 1994  Carnegie Mellon University
  7. // All rights reserved.
  8. // 
  9. // Use and copying of this software and preparation of derivative
  10. // works based on this software are permitted, including commercial
  11. // use, provided that the following conditions are observed:
  12. // 
  13. // 1. This copyright notice must be retained in full on any copies
  14. //    and on appropriate parts of any derivative works.
  15. // 2. Documentation (paper or online) accompanying any system that
  16. //    incorporates this software, or any part of it, must acknowledge
  17. //    the contribution of the Gwydion Project at Carnegie Mellon
  18. //    University.
  19. // 
  20. // This software is made available "as is".  Neither the authors nor
  21. // Carnegie Mellon University make any warranty about the software,
  22. // its performance, or its conformity to any specification.
  23. // 
  24. // Bug reports, questions, comments, and suggestions should be sent by
  25. // E-mail to the Internet address "gwydion-bugs@cs.cmu.edu".
  26. //
  27. //======================================================================
  28. //
  29. // This file implements exit and the on-exit hooks.
  30. //
  31.  
  32. define constant *on-exit* = make(<deque>);
  33.  
  34. define method exit (#key exit-code :: <fixed-integer> = 0)
  35.   while (~empty?(*on-exit*))
  36.     pop(*on-exit*)();
  37.   end;
  38.   raw-exit(exit-code);
  39. end;
  40.  
  41. define method on-exit(fun :: <function>)
  42.   push-last(*on-exit*, fun);
  43. end;
  44.